﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JumbotCms.API;
namespace JumbotCms.WebFile.Admin.Attachment
{
    public partial class _index : AdminCenter
    {
        private string _sUserUploadPath;
        private string _sUserUploadType;
        private int _sUserUploadSize = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            ChannelId = Str2Str(q("ccid"));
            Admin_Load("", "html", false);
            string strXmlFile = HttpContext.Current.Server.MapPath("~/_data/config/upload_admin.config");
            Jumbot.DataOper.XmlControl XmlTool = new Jumbot.DataOper.XmlControl(strXmlFile);
            this._sUserUploadPath = XmlTool.GetText("Module/" + ChannelType.ToLower() + "/path");
            this._sUserUploadType = XmlTool.GetText("Module/" + ChannelType.ToLower() + "/type");
            this._sUserUploadSize = Str2Int(XmlTool.GetText("Module/" + ChannelType.ToLower() + "/size"), 1024);
            XmlTool.Dispose();
            string DirectoryPath;
            DirectoryPath = site.Dir + ChannelDir + this._sUserUploadPath + "/" + DateTime.Now.ToString("yyyy-MM");
            Jumbot.Common.DirFile.CreateDir(site.Dir + ChannelDir + this._sUserUploadPath + "/" + DateTime.Now.ToString("yyyy-MM"));
            string sFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff");  // 文件名称
            string FinalFileName = DirectoryPath + "/" + sFileName;        // 最终文件路径
            //以下是通过flash将验证信息发送到地址栏
            //注意：Flash上传接收页在非IE的浏览器下获取不到Session和Cookies
            doh.Reset();
            doh.ConditionExpress = "adminid=@adminid";
            doh.AddConditionParameter("@adminid", AdminId);
            doh.AddFieldItem("MailSign", AdminPass);
            doh.Update("jcms_normal_user");
            this.flashUpload.UploadPage = "upfile.aspx";
            this.flashUpload.Args = "mailsign=" + AdminPass + ";adminid=" + AdminId + ";ccid=" + ChannelId + ";filename=" + FinalFileName;
            this.flashUpload.FinalFileName = FinalFileName;
            this.flashUpload.UploadFileSizeLimit = this._sUserUploadSize * 1024;
            this.flashUpload.FileTypeDescription = this._sUserUploadType;
        }
    }
}
